//
//  SearchCell.m
//  CarOfHome2
//
//  Created by 微 醺 on 15/10/2.
//  Copyright (c) 2015年 Frank. All rights reserved.
//

#import "SearchCell.h"
#import "SearchModel.h"

@implementation SearchCell

#pragma mark - 重写初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.iconView = [[UIImageView alloc]init];
//        self.iconView.backgroundColor = [UIColor redColor];
        self.nameLabel = [[UILabel alloc]init];
//        self.nameLabel.backgroundColor = [UIColor cyanColor];
        
        [self.contentView addSubview:self.iconView];
        [self.contentView addSubview:self.nameLabel];
        
    }
    return self;
}

#pragma mark - 重写model类set方法



#pragma mark - 布局视图
- (void) layoutSubviews
{
    
    [super layoutSubviews];
    AppDelegate *dele = [[UIApplication sharedApplication]delegate];
    if (dele.isNight == 1) {
        self.contentView.backgroundColor = [UIColor blackColor];
        self.nameLabel.textColor = [UIColor whiteColor];
    }
    else{
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.nameLabel.textColor = [UIColor blackColor];
       
    }

    self.iconView.frame = CGRectMake(SAWindth * 20, SAHeight *  10,  SAWindth * 40, SAHeight *  40);
    
    self.nameLabel.frame = CGRectMake( SAWindth * 100, SAHeight *  10,  SAWindth * 150, SAHeight *  40);
    
    self.nameLabel.font = [UIFont systemFontOfSize:17];
}


#pragma mark - 重写model类set方法
- (void) setModel:(SearchModel *)model
{
    if (_model != model) {
        _model = model;
    }
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:self.model.icon] placeholderImage:[UIImage imageNamed:@"zhuantitu.png"]];
    self.nameLabel.text = self.model.name;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
